Add smart detection to preserve .specify/ when adding agents#1506
Open
DanielHashmi wants to merge 7 commits intogithub:mainfrom
Open
Add smart detection to preserve .specify/ when adding agents#1506DanielHashmi wants to merge 7 commits intogithub:mainfrom
DanielHashmi wants to merge 7 commits intogithub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements smart detection to automatically preserve user work in the .specify/ directory when adding additional AI agents to an existing project. The key change is that running specify init in a directory with an existing .specify/ will now preserve it by default, unless the --force flag is used.
Changes:
- Added
preserve_specifyparameter todownload_and_extract_template()function to skip.specify/directory during extraction - Implemented smart detection in
init()function to detect existing.specify/directories and set preservation behavior - Updated
--forceflag description to reflect new behavior of forcing reinitialize/overwrite - Added clear user feedback panels showing whether
.specify/will be preserved or overwritten - Updated README with examples showing the new multi-agent workflow
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/specify_cli/init.py | Core implementation of smart detection and preserve_specify logic; updated function signatures and user messaging |
| README.md | Added documentation and examples for the new multi-agent workflow with automatic preservation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
|
@DanielHashmi Can you address the review comments? |
Author
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Update the user-facing init prompts to list "Command templates and workflows" and "Utility scripts and automation" as the items that will be overwritten or preserved in .specify/. This replaces prior references to specifications, implementation plans, and task lists to more accurately reflect the repository contents shown to users during reinitialization or agent addition.
…shmi/spec-kit into feature/smart-detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Smart Detection: Preserve User Work When Adding Agents
Problem
When users initialized a project with one agent and later wanted to add another agent, running
specify initagain would overwrite the.specify/directorySolution
Implement smart detection that automatically detects existing
.specify/directory and preserves user's work by default.How It Works
.specify/directory exists with content--forceflag to explicitly overwriteUser Experience
specify init . --ai claude
Work on project...
specify init . --ai copilot
✅ Automatically preserves .specify/, adds .github/ directory
Shows: "Existing project detected - preserving your work"
Key Features
✅ Safe by default - Automatically preserves existing work
✅ Intuitive - Users do what feels natural (just run init again)
✅ Clear feedback - Shows what's being preserved or overwritten
✅ Explicit override - Use --force to reinitialize
✅ Backward compatible - Existing single-agent workflow unchanged
Implementation Details
Code Changes (~100 lines)
Added:
Files Modified:
Breaking Changes
None. This is a purely additive feature that improves existing behavior.
AI Assistance
This implementation was developed with assistance from Claude Code, which was utilized for both the technical implementation and the creation of this pull request description.